import Mock from 'mockjs';
import API from '@/api/checkIn';
import {get,post,qs} from '../util';

// 配置 ajax 请求响应时间
Mock.setup({
    timeout:1000
});

// 项目模糊查询接口
Mock.mock(get(API.projectSearch),'get',function(opts){
    console.log('查询对象:',opts);
    let query = qs(opts.url);
    
    let entry = Mock.mock({
        msg:'操作成功',
        'data|1-10':[{
            'projectId|+1':100,
            'projectName':query.projectName + '@cword(3,10)'
        }]
    });
    
    return {
        code:0,
        entry:entry
    }
});

// 工种请求
Mock.mock(get(API.queryDict),'get',{
    code:0,
    entry:{
        msg:'操作成功',
        data:['泥瓦工','水电工','木工','吊车司机','挖掘机司机','安全员','安装钳工']
    }
});

// 新增记录
Mock.mock(post(API.newReworkRecord),'post',{
    code:0,
    entry:{
        msg:'操作成功'
    }
});